package com.whg.demo.biz.ureport.bean;

import com.whg.demo.mapper.StudentModelMapper;
import com.whg.demo.model.StudentModel;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author whg
 * @create 2023/3/15 14:51
 * @description：
 */
@Component
public class StudentBean {

    @Resource
    private StudentModelMapper studentModelMapper;

    public List<StudentModel> loadStudentData(String dsName,
                                              String datasetName,
                                              Map<String,Object> parameters){
        List<StudentModel> list = studentModelMapper.selectAll();
        return list;
    }

    public List<Map<String,Object>> buildStudentReport(String dsName,
                                                       String datasetName,
                                                       Map<String,Object> parameters){
        List<StudentModel> list = studentModelMapper.selectAll();
        List<Map<String,Object>> result = new ArrayList<>();
        for (StudentModel model : list){
            Map<String,Object> map = new HashMap<>();
            map.put("学校编号",model.getSchoolId());
            map.put("姓名",model.getName());
            map.put("学号",model.getId());
            result.add(map);
        }
        return result;
    }


}
